﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAO;

namespace BUS
{
    public class KhachHangBUS
    {
        KhachHangDAO khDAO = new KhachHangDAO();
        public int KiemTraLogin(string p1, string p2)
        {
            return khDAO.KiemTraLogin(p1, p2);
        }

        public DOCGIA LayThongTinDocGia(string p1, string p2)
        {
            return khDAO.LayThongTinDocGia(p1, p2);
        }
        public IQueryable loaddocgia(string ma)
        {
            var ds = khDAO.loaddocgia(ma);
            return ds;
        }
        public IQueryable loadphieumuondocgia(string ma)
        {
           // List<PHIEUMUON> l = new List<PHIEUMUON>();
            var l = khDAO.loadphieumuondocgia(ma);
            return l;
        }

        public IQueryable loadphieumuon()
        {
            // List<PHIEUMUON> l = new List<PHIEUMUON>();
            var l = khDAO.loadphieumuon();
            return l;
        }

        public IQueryable loadphieutradocgia(string ma)
        {
           // List<PHIEUMUON> l = new List<PHIEUMUON>();
            var l = khDAO.loadphieutradocgia(ma);
            return l;
        }
        public IQueryable loadchitietphieu(int ma)
        {
           // List<PHIEUMUON> l = new List<PHIEUMUON>();
            var l = khDAO.loadchitietphieu(ma);
            return l;
        }
        public IQueryable loadchitietphieutra(int ma)
        {
            // List<PHIEUMUON> l = new List<PHIEUMUON>();
            var l = khDAO.loadchitietphieutra(ma);
            return l;
        }
        
        public List<LOAISACH> loadloaisach()
        {
            List<LOAISACH> l = new List<LOAISACH>();
            l = khDAO.loadloaisach();
                return l;
        }
        public IQueryable timkiemsach(string ten, string tacgia, int maloai)
        {
            var ds = khDAO.timkiemsach(ten, tacgia, maloai);
            return ds;
        }
        public IQueryable timkiemsach2(string ten)
        {
            var ds = khDAO.timkiemsach2(ten);
            return ds;
        }
           

        
        public string CapNhatMatKhau(string mkc, string mkm, string mknl, DOCGIA dg)
        {


            if (mkc == "" || mkm == "" || mknl == "")
            {
                return "Ban chua nhap đu thong tin";
            }

            else if (string.Compare(mknl, mkm) != 0)
            {
                return "Mật Khẫu moi và mật khẩu nhập lại phải giống nhau";
            }
            else if (string.Compare(mkc, mkm) == 0)
            {
                return "Mật khẩu mới phải khác mật khẩu cũ";
            }

            else
            {
               



                if (khDAO.CapNhatMatKhau(dg, mkm) == true)
                {
                    return "Cap nhat thanh cong.";
                }
                else
                {
                    return "Cap nhat that bai.";
                }
            }

            return "";
        }

        public object loadphieutra()
        {
            var l = khDAO.loadphieutra();
            return l;
        }

        public object timkiemsachpt(string ten)
        {
            var ds = khDAO.timkiemsachpt(ten);
            return ds;
        }
    }
}
